package com.example.controller;

import com.example.util.ResultUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DemoController {

    @GetMapping("/demo1")
    @ResponseBody
    public Object demo1() {
        System.out.println("demo1");
        Subject subject = SecurityUtils.getSubject();
        System.out.println("是否登录:" + subject.isAuthenticated());
        return ResultUtil.success("请求成功", null);
    }

    @RequiresPermissions("demo2")
    @GetMapping("/demo2")
    @ResponseBody
    public Object demo2() {
        System.out.println("demo2");
        Subject subject = SecurityUtils.getSubject();
        System.out.println("是否登录:" + subject.isAuthenticated());
        return ResultUtil.success("请求成功", null);
    }
}